<template>
	<view>
		<view :style="'background-image: url('+get_img+sys.sys_background+');'" class="image"></view>
		<view>
			
			<view class="title" style="padding-top: 60rpx;">每日任务</view>
		</view>
		<view style="height: 150rpx;margin-top: 50rpx" v-for="(item,index) in list" :key="index" @click="task(item)">
			<view>
				<view style="float: left; padding-left: 20rpx; color:#fff">
					<text>{{item.title}}</text>
					<text style="font-size: 25rpx;color: yellow;">+{{item.reward}}</text>
				</view>
				<view style="float: right;padding-right: 20rpx;">
					<u-button type="primary" size="mini" @click="button" text="去完成">
					</u-button>
				</view>
			</view>
			<view style="width: 750rpx;padding-top: 60rpx;">
				<u-line-progress :percentage="get_value(item)" activeColor="#ff0000">{{get_value(item)}}%</u-line-progress>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				state: false,
				list: [],
				get_img:this.$get_img,
				sys:{}
				
			}
		},
		onLoad() {
			this.sys=uni.getStorageSync("sys")
			this.task()
		},
		methods: {
			button() {
				this.state = true;
			},
			task(item="") {
				if(item){
					uni.navigateTo({
						url:item.path
					})
				}
				
				this.$model.get("user/task/get_task").then(res => {
					if (res.code == 200) {
						this.list = res.data
						console.log(this.list)
						}
				})
			},
			get_value(item){
				let data= parseFloat(item.value)/parseFloat(item.total)
				data=parseInt(data)*100
				return data
			}
		}
	}
</script>

<style>
	.image {
		background-repeat: no-repeat;
		background-size: cover;
		background-attachment: fixed;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100vh;
		z-index: -1;
	}

	.title {
		color: #fff;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		letter-spacing: 10rpx;
		font-size: 45rpx;
	}
</style>
